package com.wd.tech.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.ButterKnife;


/**
 * @author 时文豪
 * @description:
 * @date :2020/7/2 12:00
 */
public abstract class BaseActivity<P extends BasePreantert> extends AppCompatActivity implements IBaseView{
    P mPreantert;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        mPreantert=initPreantert();
        ButterKnife.bind(this);
        initView();
        initData();
    }
    public P getmPreantert(){
        if(mPreantert!=null){
            return mPreantert;
        }
        return null;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(mPreantert!=null){
            mPreantert.datachView();
            mPreantert=null;
        }
    }

    protected abstract int getLayoutId();

    protected abstract P initPreantert();

    protected abstract void initView();

    protected abstract void initData();
}
